<?php
include_once('../../app/connection.php');

if(isset($_POST['action']))
{
    $action = $_POST['action'];
    
    if($action == "chon_hk")
    {
        $hocky = $_POST['hocky'];
        $nam = $_POST['nam'];
?>
        <table>
            <tr style="background: #247CB9;">
                <td style="text-align: center; color: #fff;">Mã lớp MH</td>
                <td style="text-align: center; color: #fff;">Tên MH</td>
                <td style="text-align: center; color: #fff;">Tên GV</td>
                <td style="text-align: center; color: #fff;">TC Lý thuyết</td>
                <td style="text-align: center; color: #fff;">TC Thực hành</td>
                <td style="text-align: center; color: #fff;">Ca</td>
                <td style="text-align: center; color: #fff;">Thứ</td>
                <td style="text-align: center; color: #fff;">Phòng</td>
                <td style="text-align: center; color: #fff;">Tối đa</td>
                <td style="text-align: center; color: #fff;">Trạng thái</td>
            </tr>
    <?php
        $sql = mysql_query("SELECT * FROM lop, monhoc, giaovien 
        WHERE lop.MAMONHOC = monhoc.MAMONHOC AND lop.MAGIAOVIEN = giaovien.MAGIAOVIEN
        AND lop.HOCKY = '$hocky' AND NAM = '$nam' ORDER BY lop.MAMONHOC, MALOP ASC");
            
        if(mysql_num_rows($sql) == 0)
            echo 'Học kỳ '.$hocky.' năm '.$nam.' không tồn tại';
        else
            while($rows = mysql_fetch_assoc($sql))
            {
    ?>
                 <tr>
                     <td style="text-align: center;"><div class="chon_ms">
                            <?php echo $rows['MAMONHOC'].'.'.$rows['MALOP']; ?></div></td>
                     <td><?php echo $rows['TENMONHOC']; ?></td>
                     <td><?php echo $rows['HOTEN']; ?></td>
                     <td style="text-align: center;"><?php echo $rows['TINCHILYTHUYET']; ?></td>                 
                     <td style="text-align: center;"><?php echo $rows['TINCHITHUCHANH']; ?></td>
                     <td style="text-align: center;"><?php echo $rows['CA']; ?></td>
                     <td style="text-align: center;"><?php echo $rows['THU']; ?></td>
                     <td style="text-align: center;"><?php echo $rows['PHONG']; ?></td>
                     <td style="text-align: center;"><?php echo $rows['TOIDA']; ?></td>
                     <td style="text-align: center;"><?php echo $rows['TRANGTHAI']; ?></td>
                     
                 </tr>
            <?php } ?>
            </table> 
<?php
    }
}
?>